import { defineStore } from "pinia";

import storage from "../../utils/storage.js";

const useMenuStore = defineStore({
  id: "app-menu",
  state: () => {
    return {
      menuHeader: storage.get("menu-header"),
      menu: storage.get("menu"),
      menuSide: storage.get("menu-side"),
      currentMenu: storage.get("current-menu"),
    };
  },
  actions: {
    setMenu(menu) {
      this.menu = menu;
      storage.set("menu", menu);
    },
    setMenuHeader(menuHeader) {
      this.menuHeader = menuHeader;
      storage.set("menu-header", menuHeader);
    },
    setMenuSide(menuSide) {
      this.menuSide = menuSide;
      storage.set("menu-side", menuSide);
    },
    setCurrentMenu(currentMenu) {
      this.currentMenu = currentMenu;
      storage.set("current-menu", currentMenu);
    },
  },
});
export default useMenuStore;
